<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/23
 * Time: 12:23
 */
$options['database'] = 0;
$options['password'] = '123456';
$options['timeout'] = 1.5;
$redis = new swoole_redis($options); //Swoole\redis

$redis->connect('127.0.0.1', 6379, function(swoole_redis $redis, $result){
    echo 'connected' .PHP_EOL;
    var_dump($result);
    /*
     * 存值
    $redis->set('singwa', time(),function(swoole_redis $redis, $result){
        var_dump($result);
    });*/
    /*
     * 取值
    $redis->get('singwa', function(swoole_redis $redis, $result){
        var_dump($result);
        $redis->close();
    });*/
    //取出redis所有key
    $redis->keys("*", function(swoole_redis $redis, $result){
        var_dump($result);
        $redis->close();
    });
    //模糊匹配redis的key值中出现gw的所有key
    $redis->keys("*gw*", function(swoole_redis $redis, $result){
        var_dump($result);
        $redis->close();
    });
    //匹配redis的key值以a打头，后面两个字符任意的所有key
    $redis->keys("a??", function(swoole_redis $redis, $result){
        var_dump($result);
        $redis->close();
    });
});